package ar.edu.utn.frsf.cidisi.ginet.generation.pnml2wscdl.elementstemplate;

import org.eclipse.emf.common.util.EList;
import org.pnml.tools.epnk.pnmlcoremodel.Page;
import org.w3._2005._10.cdl.CdlFactory;
import org.w3._2005._10.cdl.TChoice;
import org.w3._2005._10.cdl.TChoreography;
import org.w3._2005._10.cdl.TParallel;
import org.w3._2005._10.cdl.TWorkunit;

public class OrWSCDL extends WSCDLStructure {
	
	public OrWSCDL(Page page, TChoreography choreography){
		this.page = page;
		this.choreography = choreography;
	}
	
	public TParallel createWSCDLElement(){
		
		TParallel tParallel = CdlFactory.eINSTANCE.createTParallel();
		
		EList<Page> pages1 = this.getPages(page);
		
		for(int i = 0; i < pages1.size(); i++){
			TChoice choice = CdlFactory.eINSTANCE.createTChoice();
			
			TWorkunit tWorkunit = CdlFactory.eINSTANCE.createTWorkunit();
			tWorkunit.setName("or1" +i);
			TWorkunit tWorkunit2 = CdlFactory.eINSTANCE.createTWorkunit();
			tWorkunit2.setName("or2" +i);
			
			choice.getWorkunit().add(tWorkunit);
			choice.getWorkunit().add(tWorkunit2);
		    
			this.addTo(tWorkunit, this.createPackageWscdl(pages1.get(i), this.choreography));
			tParallel.getChoice().add(choice);
		}

		return tParallel;
	}
	

}
